package com.esm.controller;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.esm.model.User;
import com.esm.service.AttendService;
import com.esm.serviceimpl.AttendServiceImpl;
import com.esm.utils.PrintWriterUtil;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

/**
 * GetPerEmpYrMthOverTimeController
 * 获取单个员工时间为select year,Month,Day的加班时间
 * @author 魏长均
 *
 */
public class GetPerEmpYrMthDayOverTimeController_wcj extends HttpServlet
{
	private static final long serialVersionUID = 1L;
	AttendService aService = new AttendServiceImpl();
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException 
	{
		doPost(req, resp);
	}
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException 
	{
		HttpSession session = req.getSession();
		User currentUser = (User) session.getAttribute("currentUser");
		int uid = currentUser.getUid();
		String state_zxk = req.getParameter("state_zxk");
		int selectYear = Integer.parseInt(req.getParameter("year"));
		int selectMonth = Integer.parseInt(req.getParameter("month"));
		int selectDay = Integer.parseInt(req.getParameter("day"));
		int page = Integer.parseInt(req.getParameter("page"));
		int pageSize = Integer.parseInt(req.getParameter("rows"));
		int total = aService.getDempYrMthDayOtimeTotalRows(state_zxk, selectYear, selectMonth, selectDay, uid);
		JSONArray jao = aService.getDempYrMthDayOTimeLoad(state_zxk, selectYear, selectMonth, selectDay, uid, page, pageSize);
		
		JSONObject  jo = new JSONObject();
		PrintWriter pw = resp.getWriter();
		jo.put("total", total);
		jo.put("rows", jao);
		PrintWriterUtil.flushJoAndClosePrintWriter(pw, jo);
	}
}
